

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import beans.Person;

public class UnprivilegedServlet extends HttpServlet {

	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		Person p = (Person)req.getSession().getAttribute("person");
		List projects = Dao.getAssignedProjects(p);
		List skills = Dao.getSkills(p);
		req.setAttribute("projects", projects);
		req.setAttribute("skills", skills);
		getServletContext().getRequestDispatcher("/unprivileged-home.jsp").forward(req, resp);
	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		String jsp = "/unprivileged-home.jsp";
		String action = req.getParameter("action");
		if(action.equals("join")) {
			jsp = "/join.jsp";
		} else if(action.equals("leave")) {
			jsp = "/leave.jsp";
		} else if(action.equals("modify")) {
			jsp = "/modify.jsp";
		}

		getServletContext().getRequestDispatcher(jsp).forward(req, resp);
	}
	
}
